package com.child.java.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.child.java.dao.ChildWearMapper;
import com.child.java.pojo.ChildWearVO;
import com.child.java.service.ChildWearService;
import com.child.util.UUIDGenerter;

@Service
public class ChildWearServiceImpl implements ChildWearService {

	@Autowired
	private ChildWearMapper childWearMapper;
	
	public void plusAmount(Map<String,Object> map) {
		childWearMapper.plusAmount(map);
	}
	
	public void cutAmount(Map<String,Object> map) {
		childWearMapper.cutAmount(map);
	}
	
	@Override
	public void insert(ChildWearVO childWearVO,String wearSize) {
		if(wearSize!=null&&wearSize.length()>0){
			String[] types = wearSize.split(",");
			for(String str : types){
				ChildWearVO vo = new ChildWearVO();
				vo.setId(UUIDGenerter.getUUID());
				vo.setWearCode(childWearVO.getWearCode());
				vo.setWearType(childWearVO.getWearType());
				vo.setWearSize(Integer.parseInt(str));
				vo.setInPrice(childWearVO.getInPrice());
				vo.setOutPrice(childWearVO.getOutPrice());
				vo.setInventory(childWearVO.getInventory());
				vo.setSales(childWearVO.getSales());
				childWearMapper.insert(vo);
			}
		}
	}

	@Override
	public List<ChildWearVO> getList() {
		return childWearMapper.getList();
	}

	@Override
	public void delete(String id) {
		childWearMapper.delete(id);
	}

	@Override
	public ChildWearVO getById(String id) {
		return childWearMapper.getById(id);
	}

	@Override
	public void update(ChildWearVO childWearVO) {
		childWearMapper.update(childWearVO);
	}
	
	public List<ChildWearVO> getListByPageInfo(Map<String,Object> map){
		return childWearMapper.getListByPageInfo(map);
	}
	
	public int getListCount(Map<String,Object> map){
		return childWearMapper.getListCount(map);
	}

}
